GT-2601: Download translation files from CDN with SHA-256 verification#4424
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #4424 +/- ##
===========================================
+ Coverage 51.98% 52.08% +0.10%
===========================================
Files 454 455 +1
Lines 12075 12110 +35
Branches 2092 2097 +5
===========================================
+ Hits 6277 6308 +31
- Misses 5181 5188 +7
+ Partials 617 614 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… to API Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| async { | ||
| downloadTranslationFileIfNecessary(it).also { | ||
| val src = file.src ?: return@async true | ||
| downloadTranslationFileIfNecessary(src, sha256 = file.checksumSha256, size = file.size).also { |
There was a problem hiding this comment.
I don't understand why we're using the sha256 now. Sha256 is encryption right? What do we need to encrypt while getting the translation file?
There was a problem hiding this comment.
Sha256 is a checksum. This allows us to verify the file is what we are expecting and not corrupted
| fileName: String, | ||
| sha256: String? = null, | ||
| size: Long? = null, | ||
| ): Boolean = filesMutex.withLock(fileName) { |
There was a problem hiding this comment.
I needed to look up what a mutex is vs a semaphore again. A mutex is basically we are controlling one gate vs several with a semaphore, right?
Why do we want/use a mutex here vs a semaphore? Is it because we only deal with one file at a time in this context?
tjohnson009
left a comment
There was a problem hiding this comment.
Worked up to understanding a good bit of this. Thanks for letting me see
Summary
ApiConfigto consolidate API/CDN base URL configuration, replacing the scattered@Namedstring injectionCdnApi(Retrofit) for downloading published translation files from the CDN, with base URLs configured per flavor (mobilecontent-stage.cru.org/mobilecontent.cru.org)TranslationsApion 4xx errors orIOExceptionTest plan
IOException, both sources failing returns false, correct/wrong SHA-256 accepted/rejected, correct/wrong size accepted/rejected./gradlew :library:download-manager:testto verify all download manager tests pass./gradlew :build-logic:ktlintCheck ktlintCheckto verify code style🤖 Generated with Claude Code